import {
  Column,
  CreateDateColumn,
  Entity,
  JoinTable,
  ManyToOne,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Custom } from './theme-custom.entity';
import { User } from '../../user/entities/user.entity';
import { Bar } from './theme-bar.entity';
import { Button } from './theme-butt.entity';
import { Background } from './theme-back.entity';
import { Config } from './theme-config.entity';

@Entity('sys_theme')
export class Theme {
  @PrimaryGeneratedColumn('uuid')
  id: string;
  @Column({ type: 'varchar', default: '默认主题', length: 30 })
  name: string;
  @Column({ type: 'boolean', comment: '默认主题', default: false })
  status: boolean;
  @Column({
    type: 'int',
    comment: '删除标记 0-未删除 1-删除',
    name: 'is_delete',
    default: 0,
  })
  isDelete: number;
  @CreateDateColumn({
    type: 'timestamp',
    name: 'create_date',
    comment: '创建时间',
  })
  createDate: Date;

  @UpdateDateColumn({
    type: 'timestamp',
    name: 'update_date',
    comment: '更新时间',
  })
  updateDate: Date;
  @ManyToOne((type) => Background, (background) => background.theme)
  @JoinTable()
  background: Background;
  @ManyToOne((type) => Custom, (custom) => custom.theme)
  @JoinTable()
  custom: Custom;
  @ManyToOne((type) => Bar, (bar) => bar.theme)
  @JoinTable()
  bar: Bar;
  @ManyToOne((type) => Button, (button) => button.theme)
  @JoinTable()
  button: Button;
  @ManyToOne((type) => User, (user) => user.theme, { eager: true })
  user: User;
  @ManyToOne((type) => Config, (config) => config.theme)
  @JoinTable()
  config: Config;
}
